define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	//查询性别码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA29"},function(data){
		if("0000" === data.code){
			$scope.xbms = data.data;
			
		}else{
			alert(data.msg);
		}
	});
	
	//查询公司
	httpService.post(app.urls.unit_selectCompany,{},function(data){
		if("0000" === data.code){
			$scope.companys = data.data;
			
		}else{
			alert(data.msg);
		}
	});
	
	$scope.form.id = params.id;
	
	//查询员工
	$scope.find = function(){
		
		httpService.post(app.urls.company_selectById,$scope.form,function(data){
			if("0000" === data.code){
    			$scope.user = data.data;
    		}else{
    			alert(data.msg);
    		}
		});
	}
	
	$scope.find();
	
	$scope.saveForm = function(){
		if($scope.formCheck()) {
			$scope.user.id=params.id;
			httpService.post(app.urls.company_selectRepeatCompany,$scope.user,function(data) {
				if ("0000" === data.code) {
					httpService.post(app.urls.user_update,$scope.user,function(data) {
						if ("0000" === data.code) {
							httpService.post(app.urls.company_update, $scope.user, function (data) {
								if ("0000" === data.code) {
									var menu = {"url": "modules/content/usermanagement/company/list?father_id=" + params.father_id};
									eventBusService.publish("modules.welcome.load", menu);
								} else {
									alert(data.msg);
								}
							});
						}else {
							alert(data.msg);
						}
					});
				} else {
					alert(data.msg);
				}
			});
		}
	}
	
	
	 //返回
	$scope.goback = function(){
		var menu = {"url": "modules/content/usermanagement/company/list?father_id=" + params.father_id};
		eventBusService.publish("modules.welcome.load", menu);
	}
}}});